package cn.zyq.ykb.controller.mgt.config;

import org.springframework.security.access.prepost.PreAuthorize;
import cn.zyq.ykb.system.ry.util.poi.ExcelUtil;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.annotation.Log;
import cn.zyq.ykb.system.ry.enums.BusinessType;
import cn.zyq.ykb.beans.config.ConfigBrokerage;
import cn.zyq.ykb.service.config.ConfigBrokerageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.common.PageParam;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 配置-返佣金Controller
 *
 * @author SystemAuth
 * @date 2023-05-29
 */

@RestController(value = "MgtConfigBrokerageController")
@RequestMapping("/mgt/configBrokerage")
@Api(tags = "配置-返佣金接口")
public class ConfigBrokerageController extends BaseController {

    @Autowired
    private ConfigBrokerageService configBrokerageService;

    /**
     * 查询配置-返佣金列表
     */
    @ApiOperation(value = "列表", response = ConfigBrokerage.class)
    @PostMapping("/list")
    public Object list(@RequestBody PageParam pageParam) {
        return this.configBrokerageService.selectConfigBrokerageList(pageParam);
    }

     /**
      * 导出配置-返佣金列表
      */
     @ApiOperation(value = "导出")
     @Log(title = "配置-返佣金" , businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, ConfigBrokerage configBrokerage) {
         List<ConfigBrokerage> list = configBrokerageService.selectConfigBrokerageList(configBrokerage);
         ExcelUtil<ConfigBrokerage> util = new ExcelUtil<ConfigBrokerage>(ConfigBrokerage. class);
         util.exportExcel(response, list, "配置-返佣金数据");
     }

    /**
     * 获取配置-返佣金详细信息
     */
    @ApiOperation(value = "详情", response = ConfigBrokerage.class)
    @GetMapping(value = "/{configBrokerageID}")
    public Object getInfo(@PathVariable("configBrokerageID") Integer configBrokerageID) {
        return this.configBrokerageService.selectConfigBrokerageByConfigBrokerageID(configBrokerageID);
    }
    /**
     * 获取配置-返佣金详细信息
     */
    @ApiOperation(value = "详情", response = ConfigBrokerage.class)
    @GetMapping(value = "/detail/{serviceID}")
    public Object getInfo(@PathVariable(value = "serviceID") String serviceID) {
        return this.configBrokerageService.selectConfigBrokerageByServiceID(serviceID);
    }

    /**
     * 新增配置-返佣金
     */
    @ApiOperation(value = "新增")
    @Log(title = "配置-返佣金", businessType = BusinessType.INSERT)
    @PostMapping
    public Object add(@RequestBody ConfigBrokerage configBrokerage) {
        return this.configBrokerageService.insertConfigBrokerage(configBrokerage);
    }

    /**
     * 修改配置-返佣金
     */
    @ApiOperation(value = "编辑")
    @Log(title = "配置-返佣金", businessType = BusinessType.UPDATE)
    @PutMapping
    public Object edit(@RequestBody ConfigBrokerage configBrokerage) {
        return this.configBrokerageService.updateConfigBrokerage(configBrokerage);
    }

    /**
     * 删除配置-返佣金
     */
    @ApiOperation(value = "删除")
    @Log(title = "配置-返佣金", businessType = BusinessType.DELETE)
    @DeleteMapping("/{configBrokerageIDs}")
    public Object remove(@PathVariable Integer[] configBrokerageIDs) {
        return this.configBrokerageService.deleteConfigBrokerageByConfigBrokerageIDs(configBrokerageIDs);
    }
}
